<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Bootstrap 实例 - 水平表单</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <style>
        form{
            width: 500px;
        }
    </style>
</head>
<body>

<form class="form-horizontal" role="form" action="{:url('/loginData')}" method="post">
    <div class="form-group">
        <label for="firstname" class="col-sm-2 control-label">手机号</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" id="firstname"
                   placeholder="请输入手机号" name="phone">
        </div>
    </div>
    <div class="form-group">
        <label for="lastname" class="col-sm-2 control-label">验证码</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="code" placeholder="请输入验证码" >
            <a id="dyMobileButton" onclick="sendemail()">获取验证码</a>
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-default">登录</button>
        </div>
    </div>
</form>

</body>
</html>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
<script>
    $('#dyMobileButton').click(function (){
        var phone=$('#phone').val();
        // var countdown=60;
        // function sendemail(){
        //     var obj = $("#dyMobileButton");
        //     settime(obj);
        //
        // }
        // function settime(obj) { //发送验证码倒计时
        //     if (countdown == 0) {
        //         obj.attr('disabled',false);
        //         countdown = 60;
        //         return;
        //     } else {
        //         obj.attr('disabled',true);
        //         obj.val("重新发送(" + countdown + ")");
        //         countdown--;
        //     }
        //     setTimeout(function() {
        //             settime(obj) }
        //         ,1000)
        // }
        $.ajax({
            url:"getPhone",
            data:{phone:phone},
            type:'get',
            dataType:'json',
            success:function(e){
                console.log(e);
            }});
    })

</script>